//
//  server.h
//  api-server
//
//  Created by Peter Emil Jensen on 26/08/2012.
//  Copyright (c) 2012 Peter Emil Jensen. All rights reserved.
//

#ifndef __api_server__server__
#define __api_server__server__

#include <boost/asio.hpp>
#include <string>
#include <vector>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include "connection.h"

class server : private boost::noncopyable
{
public:
    explicit server(const std::string& address, const std::string& port, std::size_t thread_pool_size);
    
    void run();
    
private:
    void start_accept();
    
    void handle_accept(const boost::system::error_code& e);
    
    void handle_stop();
    
    std::size_t thread_pool_size_;
    
    boost::asio::io_service io_service_;
    
    boost::asio::signal_set signals_;
    
    boost::asio::ip::tcp::acceptor acceptor_;
    
    connection_ptr new_connection_;
};

#endif /* defined(__api_server__server__) */
